<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="page" value="${sessionScope.page}"/>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<c:set var="formId" value="${param.formId}"/>

<tr>
    <td colspan="5">
        共${page.totalCount}条记录 共${page.totalPage}页 每页显示${page.everyPage}条
        当前第${page.currentPage}页&nbsp;
        <c:choose>
            <c:when test="${page.hasPrePage eq false}">
                &lt&lt首页&nbsp;&lt上页&nbsp;
            </c:when>
            <c:otherwise>
                <a href="javascript:jumpPageAction('first','${formId}')">&lt&lt首页&nbsp;</a>&nbsp;
                <a href="javascript:jumpPageAction('pre','${formId}')"/>&lt上一页</a>
            </c:otherwise>
        </c:choose>
        &nbsp;||&nbsp;
        <c:choose>
            <c:when test="${page.hasNextPage eq false}">
                &nbsp;下页&gt&nbsp;尾页&gt&gt
            </c:when>
            <c:otherwise>
                <a href="javascript:jumpPageAction('next','${formId}')">下一页&gt&nbsp;</a>&nbsp;
                <a href="javascript:jumpPageAction('last','${formId}')"/>尾页&gt&gt</a>
            </c:otherwise>
        </c:choose>
        &nbsp;
        <SELECT name="indexChange" id="indexChange"
                onchange="getCurrentPage(this.value,'${formId}');">
            <c:forEach var="index" begin="1" end="${page.totalPage}" step="1">
                <option value="${index}" ${page.currentPage eq index ? "selected" : ""}>
                    第${index}页
                </option>
            </c:forEach>
        </SELECT>
        &nbsp;
        </select>
    </td>
</tr>
<script>
    function getCurrentPage(index, formId) {
        var pageActionInput = "<input type='hidden' id='pageAction' name='pageAction' value='gopage'/>"
        var pageKeyInput = "<input type='hidden' id='pageKey' name='pageKey' value='" + index + "'/>"
        $("#" + formId).append($(pageActionInput));
        $("#" + formId).append($(pageKeyInput));
        $("#" + formId).submit();
    }

    function sortPage(sortName, formId) {
        var pageActionInput = "<input type='hidden' id='pageAction' name='pageAction' value='sort'/>"
        var pageKeyInput = "<input type='hidden' id='pageKey' name='pageKey' value='" + sortName + "'/>"
        $("#" + formId).append($(pageActionInput));
        $("#" + formId).append($(pageKeyInput));
        $("#" + formId).submit();
    }

    function jumpPageAction(actionWay, formId) {
        var index = 0;
        if (actionWay == 'pre') {
            index = Number($("#indexChange").val()) - 1;
        } else {
            index = Number($("#indexChange").val()) + 1;
        }
        var pageActionInput = "";
        if (actionWay == 'first' || actionWay == 'last') {
            pageActionInput = "<input type='hidden' id='pageAction' name='pageAction' value='" + actionWay + "'/>"
        } else {
            pageActionInput = "<input type='hidden' id='pageAction' name='pageAction' value='gopage'/>"

        }
        var pageKeyInput = "<input type='hidden' id='pageKey' name='pageKey' value='" + index + "'/>"
        $("#" + formId).append($(pageActionInput));
        $("#" + formId).append($(pageKeyInput));
        $("#" + formId).submit();
    }
</script>
